package com.yunhe.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yunhe.bean.GlobalUser;
import com.yunhe.iservice.LoginIService;

/**
 * @author gyk
 * 
 * 登录实现（实验）
 *
 */
@Controller
public class LoginController {
	
	@Autowired
	private LoginIService loginIService;
	
	@RequestMapping("/userLogin")
	public void login(HttpServletRequest request,HttpServletResponse response){
		String userName=request.getParameter("username");
		String passWord=request.getParameter("password");
		
		GlobalUser globalUser=new GlobalUser();
		globalUser.setUserName(userName);
		globalUser.setPassWord(passWord);
		
		GlobalUser x=loginIService.login(globalUser);
		
		if(x!=null){
			try {
				request.getRequestDispatcher("zhuye.html").forward(request, response);
			} catch (ServletException | IOException e) {
				e.printStackTrace();
			}
		}else{
			
		}
		
	}
	
}
